from day03.base.basepage import BasePage
from appium.webdriver.common.mobileby import MobileBy


class LoginPage(BasePage):
    # 特有属性
    el_cancel = (MobileBy.ID, "android:id/button2")
    el_tiyan = (MobileBy.ID, "com.tal.kaoyan:id/activity_splash_guidfinish")
    el_username = (MobileBy.ID, "com.tal.kaoyan:id/login_email_edittext")
    el_passwd = (MobileBy.ID, "com.tal.kaoyan:id/login_password_edittext")
    el_login = (MobileBy.ID, "com.tal.kaoyan:id/login_login_btn")

    # 特有的行为
    def login(self, username, passwd):
        self.click(self.el_cancel)
        # 左滑两次
        self.swipe(0.9, 0.5, 0.3, 0.5, 500)
        self.swipe(0.9, 0.5, 0.3, 0.5, 500)
        self.click(self.el_tiyan)
        self.input(self.el_username, username)
        self.input(self.el_passwd, passwd)
        self.click(self.el_login)
    # 登录页面=base层属性及行为+当前页面类定义的属性及行为
